| Conditions | 7 |
| Total Lines | 31 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import type { ClassNamed, ClassHash } from "./defs" |
||
| 23 | |||
| 24 | function resolver( |
||
| 25 | vocabulary: undefined | Record<string, ClassHash>, |
||
| 26 | actions: Record<string, ClassHash | boolean> |
||
| 27 | ) { |
||
| 28 | const keys = $keys(actions) |
||
| 29 | |||
| 30 | for (let i = keys.length; i--;) { |
||
| 31 | const key = keys[i] |
||
| 32 | , act = actions[key] |
||
| 33 | |||
| 34 | //TODO #10 Clarify what behaviour to implement |
||
| 35 | |||
| 36 | if (act !== undefined && !act) { |
||
| 37 | // https://jsbench.me/q8kltjsdwy/ |
||
| 38 | //@ts-expect-error |
||
| 39 | keys[i] = false |
||
| 40 | continue |
||
| 41 | } |
||
| 42 | |||
| 43 | const hash = vocabulary?.[key] |
||
| 44 | if (hash !== undefined) |
||
| 45 | keys[i] = hash |
||
| 46 | else if (typeof act === "string") |
||
| 47 | keys[i] = act |
||
| 48 | } |
||
| 49 | |||
| 50 | // https://jsbench.me/9mklnonq0m |
||
| 51 | const filtered = keys.filter(x => x) |
||
| 52 | |||
| 53 | return filtered.length === 0 ? EMPTY_ARRAY : filtered |
||
| 54 | } |
||
| 68 |